package controller;

import service.TableService;
import util.JsonUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/table/update")
public class TableUpdateController extends HttpServlet {
    private TableService ts = new TableService();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //接收前台表单提交的数据
        String id = req.getParameter("id");
        String ordId = req.getParameter("ordId");
        String num = req.getParameter("num");
        String flag = req.getParameter("flag");
        String description = req.getParameter("description");
        //执行修改
        int f = ts.update(ordId, num, flag, description,id);
        if (f != 0) {
            //修改成功
            JsonUtils.jsonWrite(resp,"修改成功");
        }else {
            JsonUtils.jsonWrite(resp,"修改失败，检查代码是否出错");
        }
    }
}
